// 加载公共css文件
// #ifndef APP-NVUE
  import './scss/index.scss';
// #endif

// 初始化api
import {createInstance as createApiInstance}  from './common/api.js';

// 初始化store
import {createInstance as createStoreInstance}  from './common/store.js';

// computed 初始化computed
import computeds from './computed/index.js';
import methods from './methods/index.js';
import filters from './filters/index.js';
import {customMethod,customComputed,customFilter} from './common/mixin.js';
 
export default {
  install(Vue, options) {
    Vue.prototype.$apis = createApiInstance(Vue, options['api']);
    Vue.prototype.$store = createStoreInstance(Vue, options['store']);
    
    // 初始化基础 filters,methods，computeds
    let defaultMixin = {
      filters,
      methods,
      computeds
    };
    
    // 按需加载 methods
    let newMethods = {
      ...defaultMixin.methods, 
      ...customMethod(options.methods||[])
    }
    
    let newFilters = {
      ...defaultMixin.filters, 
      ...customFilter(options.filters||[])
    };
    
    let newComputeds = {
      ...computeds,
      ...customComputed(options.computeds||[])
    }
    
    Vue.mixin({
      filters:newFilters,
      methods:newMethods,
      computed:newComputeds
    });
    
    console.log('api store init');
    uni.$emit('launch');
  },
};